<?php

namespace app\admin\controller;

use app\common\service\Status;
use think\Controller;
use buildView\Detail;
use buildView\Form;
use buildView\Grid;
use app\common\model\ShopMemberCard;

/**
 * 会员卡管理
 * Class MemberCard
 * @package app\admin\controller
 */
class MemberCard extends Controller
{
    /**
     * 列表
     * @auth true
     * @menu true
     * @return string
     */
    public function index()
    {
        $grid = new Grid(new ShopMemberCard);
		$grid->column('name','卡名称');
		// $grid->column('type','类型')->using(Status::CARDTYPE())->badge();
		$grid->column('money','需支付金额');
		$grid->column('wash_number','可清洗次数');
		$grid->column('effective_date','有效天数');
        $grid->column('status', '上架状态')->align('left')->switchs([
            'on' => ['text' => '启用', 'value' => 1],
            'off' => ['text' => '禁用', 'value' => 0],
        ]);
		$grid->column('create_at','添加时间');
		$grid->filter(function ($filter){
            $filter->dateBetween('create_at','添加时间');
        });
        $grid->hideExportButton();
        $grid->actions(function ($action){
        	 $action->hideDetail();
        });
        return $grid->view();
    }

    /**
     * 添加/编辑
     * @auth true
     * @menu true
     * @return string
     */
    public function form()
    {
        $form = new Form(new ShopMemberCard);
		$form->text('name','名称')->required();
        $form->text('describe','权益说明');
        $form->image('img','img')->required();
         $form->select('type', '会员卡类型')->options(Status::CARDTYPE())->default(1);
		//$form->date('birthday','生日');
		$form->number('money','需支付金额');
		$form->number('wash_number','可清洗次数');
        $form->number('bed_num','其中床品次数')->help('可清洗总次数中的洗床品次数');
		$form->number('effective_date','有效天数');
		$form->ckeditor('content','权益说明');
        return $form->view();
    }
}
